/**
 * 
 */
package com.wubo.bm.common.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.wubo.bm.common.acl.ResponseAcl;
import com.wubo.sec.acl.core.AclModel;
import com.wubo.sec.acl.core.GlobalAcl;
import com.wubo.sec.model.User;

/**
 * 回复
 * @author WuBo
 * @CreateDate 2012-2-24 上午09:13:52
 */
@Entity
@Table(name="Response")
public class Response implements AclModel {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer id;
	private String content;
	private Date emitDate; //发表日期
	@ManyToOne(targetEntity=User.class, fetch=FetchType.EAGER)
	@JoinColumn(name="username")
	private User user; //用户名
	private boolean audited; //是否已审核
	private String ip; //发表人IP
	private int type; //回复类型
	private int typeId; //回复类型Id
	private Integer parentId; //引用
	
	@Transient
	public List<Response> subResponses;
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public Date getEmitDate() {
		return emitDate;
	}
	public void setEmitDate(Date emitDate) {
		this.emitDate = emitDate;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public String getIp() {
		return ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public int getTypeId() {
		return typeId;
	}
	public void setTypeId(int typeId) {
		this.typeId = typeId;
	}
	public Integer getParentId() {
		return parentId;
	}
	public void setParentId(Integer parentId) {
		this.parentId = parentId;
	}
	public boolean isAudited() {
		return audited;
	}
	public void setAudited(boolean audited) {
		this.audited = audited;
	}
	
	public List<Response> getSubResponses() {
		return subResponses;
	}
	public void setSubResponses(List<Response> subResponses) {
		this.subResponses = subResponses;
	}

	@Override
	public GlobalAcl getAcl() {
		return new ResponseAcl(this);
	}
}
